<!-- head -->
{include file='public/head' /}
<!-- head -->

<!-- left -->
{include file='public/left' /}
<!-- left -->

<div class="content-wrapper">
    <section class="content-header">
        <h1>
            拓客红包
            <small>所有拓客红包</small>
        </h1>
        <ol class="breadcrumb">
            <li><a href="#"><i class="fa fa-dashboard"></i> 店铺管理</a></li>
            <li>店铺列表</li>
            <li>查看详情</li>
            <li class="active">拓客红包</li>
        </ol>
    </section>

    <section class="content">
        <div class="row">
            <div class="col-sm-12">
                <div class="box box-primary">
                    <div class="box-header with-border">
                        <h3 class="box-title">共计{$redlist->total()}条记录</h3>
                        <div class="box-tools pull-right">
                            <button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i>
                            </button>
                            <button type="button" class="btn btn-box-tool" data-widget="remove"><i class="fa fa-times"></i></button>
                        </div>
                    </div>
                    <div class="box-body">
                        <div class="table-responsive">
                            <table class="table table-bordered table-striped">
                                <form id='iform' action="{:url('Store/redpacket')}" method="get">
                                    <div class="input-group">
                                        <input type="hidden" value="{$id}" name="id">
                                        <input type="text" name="number" id="number" value="{$number}" class="form-control" style="width: 50%;" placeholder="请输入要导出的开始编号...">
                                        <select class="form-control select2" style="width: 50%;" name="status" id="status">
                                            <option selected="selected" value="0">全部</option>
                                            <option value="1" {if condition="$status eq 1"}selected{/if}>已兑换</option>
                                            <option value="2" {if condition="$status eq 2"}selected{/if}>未兑换</option>
                                        </select>

                                        <span class="input-group-btn">
                                            <button type="submit" name="search" id="search-btn" class="btn btn-flat"><i class="fa fa-search"></i></button>
                                            <button type="button" class="btn btn-flat bg-olive" data-url="{:url('Store/redpacketExcel','','')}" onclick="storeExcel(this)"><i class="fa fa-download"></i></button>
                                            <button type="button" class="btn btn-flat bg-orange" data-url="{:url('Store/addredpacket','','')}" onclick="makeredpacket(this)"><i class="fa fa-plus">添加</i></button>
                                        </span>
                                    </div>
                                </form>
                                <thead>
                                    <tr>
                                        <th>编号</th>
                                        <th>兑换码</th>
                                        <th>金额</th>
                                        <th>状态</th>
                                        <th>兑换人手机号</th>
                                        <th>兑换时间</th>
                                        <th>添加时间</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    {volist name='redlist' id='admin'}
                                    <tr>
                                        <td>{$admin.id}</td>
                                        <td>{$admin.redeem_code}</td>
                                        <td>{$admin.money}</td>
                                        <td>
                                        {if condition="$admin.status eq 1"}已兑换{else/}未兑换{/if}
                                        </td>
                                        <td>{$admin.custom_phone}</td>
                                        <td>
                                        {if condition="$admin.get_time neq ''"}
                                        {$admin.get_time|date='Y-m-d H:i',###}
                                        {else/}未兑换
                                        {/if}
                                        </td>
                                        <td>{$admin.add_time|date='Y-m-d H:i',###}</td>
                                    </tr>
                                    {/volist}
                                </tbody>
                            </table>
                        </div>
                    </div>
                    <div class="box-footer clearfix" style="text-align: center">
                        {$redlist->render()}
                    </div>
                </div>
            </div>
        </div>
    </section>
</div>
<script type="text/javascript">
    function storeExcel(obj) {
    var url = $(obj).data('url');
    var number = window.document.getElementById('number').value;
    var status = window.document.getElementById('status').value;
    var id = "{$id}";
    if(number==''){
        number=0;
    }
    window.location.href = url + '/number/' + number + '/status/' + status +'/id/'+id;
    }
    
    function makeredpacket(obj) {
    var url = $(obj).data('url');
    var id = "{$id}";
    window.location.href = url +'/id/'+id;
    }
</script>

<!-- foot -->
{include file='public/foot' /}
<!-- foot -->